package tblModelTafel;


import java.util.ArrayList;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import pnlRestaurant.PnlResMain;
import daoDataFactory.DaoFactory;
import domijn.Tafel;



public class TMTafel implements TableModel {
	
	
	@SuppressWarnings("unused")
	private PnlResMain PnlResMain;
	private String []names = {" Nummer"};
	private ArrayList<Tafel> altafel;
	private Tafel t;

	public TMTafel(PnlResMain pnlResMain) {
		this.PnlResMain = pnlResMain;
		altafel = DaoFactory.getwokapplicatie().getDaoITafel().loadall();   
        }

	@Override
	public int getRowCount() {
		return altafel.size();
	}

	@Override
	public int getColumnCount() {
		return names.length;
	}
	
	@Override
	public String getColumnName(int column) {
		return names[column];
	}

	@Override
	public Class<Tafel> getColumnClass(int column) {
		return Tafel.class;
	}

	@Override
	public boolean isCellEditable(int arg0, int arg1) {
		return false;
	}
	
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		t = altafel.get(rowIndex);
		 switch (columnIndex){
         case 0:
              return t.getTflNumber();
      
            }
        return t;
        }
	
	@Override
	public void setValueAt(Object arg0, int arg1, int arg2) {
	}
	
	@Override
	public void addTableModelListener(TableModelListener arg0) {
	}
	
	@Override
	public void removeTableModelListener(TableModelListener arg0) {
	}
	
    public void addTafel(final Tafel tafel) {
    	altafel.add(tafel);
    }
    
	
}